<?php
/*
* index.dir.php
* 
* Creado por udomos el 13 de diciembre del 2010.
* Última modificación por udomos el 13 de diciembre del 2010.
* Derechos Reservados a Udomos S.A. de C.V. 2010.
*/

// load config file
require_once ($_SERVER["DOCUMENT_ROOT"] . '/config/config.php');
// load date functions file
require_once ($_SERVER["DOCUMENT_ROOT"] . '/modules/functions/date_functions.php');
// load string functions file
require_once ($_SERVER["DOCUMENT_ROOT"] . '/modules/functions/string_functions.php');

/*=====	BASE DE DATOS	=====*/

$mdb2 =& MDB2::connect($dsn, $opt);

if (PEAR::isError($mdb2))
	die('Could not connect: '. $mdb2->getMessage());
else{ 
	$S = "";
	$IDS = 0;
	
	if(isset($_POST['page'])) {
		$I = $_POST['page'];
		$I = ($I*$_TDL)-$_TDL;
	}
	
	else $I = 0;	
	$L = $_TDL;
	
	if(isset($_POST['ent-search'])) {
	$S = strtolower(utf8_decode(addslashes($_POST['ent-search'])));
	}
	$S2 = explode(" ",noPrep($S,$arrayRem));
	foreach($S2 as $W){
		$IDspo = _SA("SELECT owe_IDowe FROM uwordsEnterprise 
						JOIN enterprise ON ent_IDenterprise = owe_id_enterprise 
						WHERE LOWER(owe_word)='$W' GROUP BY ent_IDenterprise","owe_IDowe","owe_IDowe");
		if(count($IDspo)>0){$IDS = implode(",",$IDspo);}
	}

	foreach($S2 as $W){
		$AND .= " AND LOWER(CONCAT(ent_tags,' ',ent_name,' ',ent_info,' ',ent_products,' ',ent_services)) LIKE '%$W%'";
	}
	$FROM = "FROM enterprise 
				JOIN sucursal ON suc_id_enterprise = ent_IDenterprise
			WHERE suc_IDsucursal NOT IN($IDS) $AND";
	
	$counter = _SF("SELECT COUNT(suc_IDsucursal) AS counter $FROM","counter")+count($IDS);
} 

	$counter = $counter/$_TDL;
	if(!is_int($counter)) $counter = ceil($counter);
	
	 
	
	if($counter > 0){
		 echo "<ul id='mycarousel' ";
		 if($counter >=15) echo "class='jcarousel-skin-tango'>"; else echo ">";
		 for($i=1;$i<=$counter;$i++){	 
		 	echo "<li><span title='$i' class='";
			if($i == 1) echo "disabled-paginator"; else echo "enable-paginator";
			echo "'>$i</span></li>"; 	
		 }
		 echo "</ul>";
	 }
	 
	 
?>	
<script type="text/javascript">
	jQuery(document).ready(function() {
		jQuery('#mycarousel').jcarousel({
			wrap		:'both',
			visible		:15,
			scroll		:15,
		});
	});
</script>